﻿using Swashbuckle.Swagger;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Http.Description;

namespace IOA.MES.PdaApi
{
    public class SwaggerHeaderFilter : IOperationFilter
    {
        public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)
        {
            if (operation == null) return;

            if (operation.parameters == null)
            {
                operation.parameters = new List<Parameter>();
            }

            var tokenParameter = new Parameter
            {
                description = "Token令牌",
                @in = "header",
                name = "Token",
                required = false,
                type = "string",
            };
            operation.parameters.Add(tokenParameter);

            var warehouseParameter = new Parameter
            {
                description = "仓库代码",
                @in = "header",
                name = "WarehouseCode",
                required = false,
                type = "string",
            };
            operation.parameters.Add(warehouseParameter);
        }
    }
}
